package com.cxc.news.config;

import com.cxc.news.interceptor.AdminInterceptor;
import com.cxc.news.interceptor.LoginInterceptor;
import com.cxc.news.interceptor.TypeInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 扩展SpringMVC的配置类
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    TypeInterceptor typeInterceptor;
    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/backstage/**","/publishs");
        registry.addInterceptor(typeInterceptor)
                .addPathPatterns("/**");
        registry.addInterceptor(new AdminInterceptor())
                .addPathPatterns("/admin/**");

    }
}
